<template>
  <el-dialog
    v-if="dialogVisible"
    :visible.sync="dialogVisible"
    :close-on-click-modal="false"
    :before-close="handleClose"
    :title="`${$t('generateRequisition')}`"
    width="60%">
    <component
      ref="componentRef"
      :is="currentTag"
      :form-info="formInfo"
      :table-list="tableList"
      @handleClose="handleClose"
      @doGenerate="doGenerate"
      @initList="handleClose"
      @getFormInfo="getFormInfo"/>
  </el-dialog>
</template>

<script>
// import collectForm from './collectForm'
// import baseInfoTable from './baseInfo'
export default {
  name: 'CreateList',
  components: {
    collectForm: () => import('./collectForm'),
    baseInfoTable: () => import('./baseInfo')
  },
  props: {},
  data() {
    return {
      dialogVisible: false,
      currentTag: 'collectForm',
      formInfo: {},
      tableList: []
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    getInfo() {},
    // 生成
    doGenerate() {
      this.currentTag = 'baseInfoTable'
    },
    getFormInfo(val) {
      this.formInfo = val
      this.tableList = val.suitsToolingList
      delete this.formInfo.suitsToolingList
    },
    handleOpen() {
      this.dialogVisible = true
    },
    handleClose() {
      if (this.formInfo.prelendNo) {
        this.handleUpdate()
      }
      this.$refs.componentRef.emptyForm()
      Object.assign(this.$data, this.$options.data.call(this))
    },
    // 触发父组件更新
    handleUpdate() {
      this.$emit('initList')
    }
  }
}
</script>

<style scoped lang="scss">
</style>
